import os
import csv
import base64
def read_text_file(file_name):
    abs_path = os.path.join("data", file_name)
    with open(abs_path, "r", encoding="utf-8") as f:
        content = f.read()
    return content

def read_csv_file(file_name):
    abs_path = os.path.join("data", file_name)
    with open(abs_path, 'r', encoding='utf-8') as f:
        reader = csv.reader(f)
        return [row for row in reader]

def encode_images(image_files):
    img_base64_list = []
    
    for img_file in image_files:
        img_path = os.path.join("data", img_file)
        if os.path.exists(img_path):
            with open(img_path, "rb") as f:
                img_bytes = f.read()
                img_base64 = base64.b64encode(img_bytes).decode("utf-8")
                img_base64_list.append(f"data:image/png;base64,{img_base64}")

    return img_base64_list
